﻿using Core.Domain.Entities;
using Core.Migrations.Extensions;
using FluentMigrator;

namespace Infrastructure.Persistence.Migrations.Organizations;

[Migration(202510242211)]
public class CreateColumn : ForwardOnlyMigration
{
    public override void Up()
    {
        Alter.Table(typeof(Organization).GetTableName())
          .InSchema(SchemaNames.Identity)
          .AddColumn("TenantId").AsString(100).Nullable().WithColumnDescription("租户标识")
          .AddColumn(MigrationExpressions.ColumnNameFor<Organization>(nameof(Organization.Name))).AsString(100).Nullable().WithColumnDescription("名称")
          .AddColumn(MigrationExpressions.ColumnNameFor<Organization>(nameof(Organization.Code))).AsString(100).Nullable().WithColumnDescription("编码")
          .AddColumn(MigrationExpressions.ColumnNameFor<Organization>(nameof(Organization.ParentId))).AsGuid().Nullable().Indexed("IX_Organizations_ParentId").WithColumnDescription("父节点");
    }
}
